# We need to add the directory of the graphics API to the PATH somehow.
# Main file for Endian
import os, sys

SCRIPTS_DIR = os.path.abspath('scripts')

def _fix_pypath():
    """ Changes the sys.path variable to include the scripts directory. """
    # Failsafe for calling it twice or more.
    if SCRIPTS_DIR not in sys.path:
        sys.path.append(SCRIPTS_DIR)
    else:
        # We don't need to do anything.
        return

def main():
    _fix_pypath()

    from vital import constwrap, engine

    sys.modules['vital.engine'] = constwrap.ConstWrap(engine.Engine())

    # We still have a reference to the original 'engine' module with us. Because of this, we need to use sys.modules to start the game engine.
    global status
    status = sys.modules['vital.engine'].start_game()

status = 0

if __name__ == '__main__':
    try:
        main()
    except KeyboardInterrupt:
        sys.exit(status)
sys.exit(status)
